{extend name="public/base" /}
{block name="style"}
{/block}
{block name="body"}
<div class="page-header">
    <h4>{notempty name="title_bar"}
        {$title_bar}
        {else/}
        {$meta_title}
        {/notempty}
    </h4>
</div>
    <!-- 标签页导航 -->
<div class="tab-wrap">
    {php}
    $model = $model_info;
    $fields = $model_info['fields'];
    {/php}
    <ul class="tab-nav nav nav-tabs">
        {volist name=":parse_config_attr($model['field_group'])" id="group"}
        <li data-tab="tab{$key}" {eq name="key" value="1"}class="current"{/eq}><a href="javascript:void(0);">{$group}</a></li>
        {/volist}
    </ul>
    <div class="two-tab-content">
        <!-- 表单 -->
        <form id="form" action="{notempty name="model_info.url"}{$model_info['url']}{/notempty}" method="post" class="form-horizontal">
            <!-- 基础文档模型 -->
            {volist name=":parse_config_attr($model['field_group'])" id="group"}
            <div id="tab{$key}" class="tab-pane {eq name="key" value="1"}in{/eq} tab{$key}">
                {volist name="fields[$key]" id="field"}
                {if condition="!isset($field['is_show']) || $field['is_show'] == 1 || $field['is_show'] == 2"}
                <div class="form-item cf">
                    <label class="item-label">{$field['title']}<span class="check-tips">{notempty name="field['remark']"}（{$field['remark']}）{/notempty}</span></label>
                    <div class="controls">
                        {switch name="field.type"}
                        {case value="num"}
                        <input type="text" class="text input-mid" name="{$field.name}" value="{$data[$field['name']]|default=''}">
                        {/case}
                        {case value="string"}
                        <input type="text" class="text input-large" name="{$field.name}" value="{$data[$field['name']]|default=''}">
                        {/case}
                        {case value="textarea"}
                        <label class="textarea input-large">
                            <textarea name="{$field.name}">{$data[$field['name']]|default=''}</textarea>
                        </label>
                        {/case}
                        {case value="date"}
                        <input type="text" name="{$field.name}" class="text date" value="{$data[$field['name']]|strtotime|date='Y-m-d',###}" placeholder="请选择日期" />
                        {/case}
                        {case value="datetime"}
                        <input type="text" name="{$field.name}" class="text time" value="{$data[$field['name']]|strtotime|time_format}" placeholder="请选择时间" />
                        {/case}
                        {case value="bool"}
                        <select name="{$field.name}">
                            {volist name=":parse_field_attr($field['extra'])" id="vo"}
                            <option value="{$key}" {eq name="data[$field['name']]" value="$key"}selected{/eq}>{$vo}</option>
                            {/volist}
                        </select>
                        {/case}
                        {case value="select"}
                        <select name="{$field.name}">
                            {volist name=":parse_field_attr($field['extra'])" id="vo"}
                            <option value="{$key}" {eq name="data[$field['name']]" value="$key"}selected{/eq}>{$vo}</option>
                            {/volist}
                        </select>
                        {/case}
                        {case value="radio"}
                        {volist name=":parse_field_attr($field['extra'])" id="vo"}
                        <label class="radio">
                            <input type="radio" value="{$key}" {eq name="data[$field['name']]" value="$key"}checked="checked"{/eq} name="{$field.name}">{$vo}
                        </label>
                        {/volist}
                        {/case}
                        {case value="checkbox"}
                        {php}
                        if(is_array($data[$field['name']])){
                            $data[$field['name']] = array_flip($data[$field['name']]);
                        }
                        {/php}
                        {volist name=":parse_field_attr($field['extra'])" id="vo"}
                        <label class="checkbox">
                            <input type="checkbox" value="{$key}" name="{$field.name}[]" {php}if(isset($data[$field['name']][$key])){ echo 'checked="checked"'; };{/php} >{$vo}
                        </label>
                        {/volist}
                        {/case}
                        {case value="disabled"}
                        <input type="text" disabled="disabled" class="text input-mid" name="{$field.name}" value="{:parse_field_attr($field['extra'],$data,$data[$field['name']])}">
                        {/case}
                        {case value="editor"}
                        <label class="textarea">
                            <textarea name="{$field.name}">{$data[$field['name']]}</textarea>
                            {:hook('adminArticleEdit', array('name'=>$field['name'],'value'=>$data[$field['name']]))}
                        </label>
                        {/case}
                        {case value="widget"}
                            {php}
                            $hook_arr = parse_function_attr($field['extra'],$data);
                            {/php}
                            {:widget($hook_arr['name'],[$hook_arr['parameter']])}
                        {/case}
                        {case value="function"}
                        {php}
                        $hook_arr = parse_function_attr($field['extra'],$data[$field['name']]);
                        {/php}
                        {:$hook_arr['name']($hook_arr['parameter'])}
                        {/case}
                        {case value="hook"}
                        {php}
                        $hook_arr = parse_function_attr($field['extra'],$data[$field['name']]);
                        {/php}
                        {:hook($hook_arr['name'],$hook_arr['parameter'])}
                        {/case}
                        {case value="picture"}
                            {:hook('webuploader',['name'=>$field['name'],'value'=>$data[$field['name']],'type'=>'docunment'])}
                        {/case}
                        {case value="file"}
                            {:hook('webuploader',['name'=>$field['name'],'value'=>$data[$field['name']],'type'=>'download'])}
                        {/case}
                        {default/}
                        <input type="text" class="text input-large" name="{$field.name}" value="{$field.value|default=''}">
                        {/switch}
                    </div>
                </div>
                {elseif condition="$field['is_show'] == 3 || $field['is_show'] == 4 || $field['is_show'] == 6"/}
                {php}
                if(isset($field['extra']) && !empty($field['extra']) && empty($data[$field['name']])){
                    $data[$field['name']] = parse_field_attr($field['extra']);
                }
                {/php}
                <!--隐藏表单-->
                <input type="hidden" class="text input-large" name="{$field.name}" value="{$data[$field['name']]|default=''}">
                {/if}
                {/volist}
            </div>
            {/volist}
            <div class="form-item form-submit">
                {notempty name="model_info['url']"}
                <button class="btn submit-btn ajax-post btn-danger" id="submit" type="submit" target-form="form-horizontal">确 定</button>
                {/notempty}
                <a class="btn btn-return btn-success" href="#" onclick="javascript:history.back(-1);return false;">返 回</a>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="script"}
<link href="__PUBLIC__/static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="__PUBLIC__/static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__PUBLIC__/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
    //导航高亮
    {php}
        $url = isset($highlight_subnav)?$highlight_subnav:url(request()->action());
    {/php}
    var gl_id = $('.side-sub-menu').find('a[href="{$url}"]').html();
    if((gl_id == "" || gl_id == undefined || gl_id == null)){
        highlight_subnav('{:url("index")}');
    }else {
        highlight_subnav('{$url}');
    }

    $(function(){
        $('.date').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });
        $('.time').datetimepicker({
            format: 'yyyy-mm-dd hh:ii',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });
        showTab();
    });
</script>
{/block}
